#include <stdio.h>
#define LEN 80
int is_within(const char * str, char c);
int main(void)
{
    char input[LEN];
    char ch;
    int found;;
    
    printf("Enter a string: ");
	// 获取输入字符，如果第一个字符是换行，则程序结束
    while (gets(input) && input[0] != '\0')
    {
        printf("Enter a character: ");
        ch = getchar();
	// 直到输入换行符的时候才进行后面的程序
        while (getchar() != '\n')
            continue;
        found = is_within(input, ch);
        if (found == 0)
            printf("%c not found in string.\n", ch);
        else
            printf("%c found in string %s\n", ch, input);
        printf("Next string: ");
    }
    puts("Done.\n");
    
    return 0;
}

int is_within(const char * str, char ch)
{
    while (*str != ch && *str != '\0')
        str++;
    return *str;   /* = 0 if \0 reached, non-zero otherwise */
}

